pin=0
gpio.mode(pin,gpio.OUTPUT)
gpio.write(pin,gpio.HIGH)

-- 2 txd 发 3 rxd 收
s = softuart.setup(9600,2,3)
s:on("data","$",function (data)    -- 以 $ end
    cmd = string.sub(data, 1, #data -1)
    print(cmd)
    s:write("ok")
    if cmd == "on" then
        gpio.write(pin,gpio.LOW)
    elseif cmd == "off" then
        gpio.write(pin,gpio.HIGH)
    end
end) 
